/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { Request, Response } from 'express';
import { ResponseItem, responseSuccess } from '../utils';
import Mock, { mock } from 'mockjs';

export default {
  'POST /jdk/League/merchantSearch': (req: Request, res: Response) => {
    const { pageSize = 20 } = req.body;
    const data = Mock.mock({
      [`list|${pageSize}`]: [
        {
          'id|+1': 1,
          'league_id|1': ['0', '@id()'],
          user_id: '@id()',
          created_at: '@date()',
          phone: '13783636924',
          league_name: '@cname(3)' + '加盟商',
          'is_black|1': ['0', '1'],
          'shop_address_list|0-2': ['@county(true)'],
          'shop_count|1-100': 100,
          'delivery_count|1-100': 100,
          'league_source_name|1': ['直属', '加盟'],
          'try_delivery_count|1-1000': 1000,
          'shop_list|0-3': [
            {
              shop_name: '@cname(3)',
            },
          ],
          staff_name: '@cname(3)',
          'shunfen|1': [{ type: 2, brands: ['ddks'], time: 30 }],
        },
      ],
    });

    let result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: {
        ...data,
        total: data.list.length * 2,
      },
    };
    return res.json(result);
  },
  'POST /jdk/League/search': (req: Request, res: Response) => {
    const { league_name } = req.body;
    const data = Mock.mock({
      'list|1-30': [
        {
          league_id: '@id()',
          league_name: '@cname(3)',
          phone: '13783636923',
        },
      ],
    });

    let result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: league_name ? data : [],
    };
    return res.json(result);
  },
  'POST /jdk/League/listStaff': (req: Request, res: Response) => {
    const { league_id } = req.body;
    const data = Mock.mock({
      'list|1-30': [
        {
          id: '@id()',
          name: '@cname(3)',
          phone: '13783636923',
        },
      ],
    });

    let result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: league_id ? data : [],
    };
    return res.json(result);
  },
  'POST /jdk/League/bind': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/League/unbind': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/League/getRemarkList': (req: Request, res: Response) => {
    const data = Mock.mock({
      'list|1-30': [
        {
          id: '@id()',
          user_id: '@id()',
          create_time: '@now()',
          operate_name: '@ctitle(5)',
          remark: '@cword(5, 10)',
          operate_phone: '13783636923',
        },
      ],
    });

    const result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: data.list,
    };
    return res.json(result);
  },
  'POST /jdk/League/remark': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/League/black': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/League/unblack': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/League/oneClickRegister': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/League/setLeagueShunfen': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/League/setMerchantShunfen': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/League/resetLeagueShunfen': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/League/resetMerchantShunfen': (req: Request, res: Response) =>
    responseSuccess(req, res),
  'POST /jdk/chain/bind': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/chain/unbind': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/League/merchantDetail': (req: Request, res: Response) => {
    const result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: mock({
        'id|+1': 1,
        'league_id|1': ['0', '@id()'],
        user_id: '@id()',
        created_at: '@date()',
        phone: '13783636924',
        league_name: '@cname(3)',
        chain_name: '@cname(3)',
        'is_black|1': ['0', '1'],
        'shop_address_list|0-2': ['@county(true)'],
        'shop_count|1-100': 100,
        'delivery_count|1-100': 100,
        'league_source_name|1': ['直属', '加盟'],
        'try_delivery_count|1-1000': 1000,
        'is_self_delivery|1': ['0', '1'],
        'shop_list|0-3': [
          {
            shop_name: '@cname(3)',
          },
        ],
        'delivery_status|1': ['1', '2'],
        'shunfen|1': [{ type: 1, brands: [], time: 30 }], //[{ type: 1, brands: [], time: 0 }, ''],
        chain_name: '@cname(3)',
        'chain_user_id|1': ['0', '@id()'],
      }),
    };
    return res.json(result);
  },
  'POST /jdk/shop/list': (req: Request, res: Response) => {
    const data = Mock.mock({
      'list|2': [
        {
          category_id: '4',
          category_title: '日用百货',
          city: '苏州市',
          completely_addr: '苏州市江苏省昆山花桥镇绿地大道788号国际华城',
          contact_mobile: '18516011018',
          contact_person: '',
          contact_tel: '',
          created_at: '2022-07-05 11:44:59',
          delivery_name: '帮啦跑腿',
          district: '昆山',
          fnps_store_id: '212253987',
          'id|+1': 1,
          latitude: '31.294747',
          league_id: '124322099',
          location: '花桥镇绿地大道788号国际华城',
          location_poi: '国际华城(西门)',
          longitude: '121.100141',
          order_receive_type: '1',
          province: '江苏省',
          room_number: '门口电联',
          shop_name: 't昆山聚单客',
          updated_at: '2022-08-26 15:29:39',
          'user_id|+1': 1,
        },
      ],
    });
    const result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: {
        ...data,
        total: data.list.length,
      },
    };
    return res.json(result);
  },
  'POST /jdk/delivery/addAccount': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/shop/bindKeruyun': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/League/getServiceFeeByMerchat': (req: Request, res: Response) => {
    return res.send({
      code: 0,

      msg: 'success',

      data: [
        {
          ratio: 50,

          brand: 'kb',

          brand_name: '商家自配送',

          admin_league_base_price: 0,

          admin_base_price_status: 1,

          admin_base_price: 1,

          real_base_price_expire_at: '2038-01-01 00:00:00',

          admin_base_price_expire_at: '2038-01-01 00:00:00',

          league_base_price_status: 0,

          league_base_price: '',

          league_base_price_expire_at: null,

          real_base_price: 1,

          service_fee_enable: null,

          service_fee_expire_type: null,
        },

        {
          ratio: 50,

          brand: 'jfkp',

          brand_name: '飓风快跑',

          admin_league_base_price: 0,

          admin_base_price_status: 0,

          admin_base_price: '',

          admin_base_price_expire_at: null,

          league_base_price_status: 0,

          league_base_price: '',

          league_base_price_expire_at: null,

          real_base_price: 0,

          service_fee_enable: null,

          service_fee_expire_type: null,
        },
      ],
    });
    const data = Mock.mock({
      'list|2': [
        {
          brand: 'gxd',
          brand_name: '裹小递',
          'admin_league_base_price|1': [20, ''],
          'league_base_price|1': [12, ''],
          'real_base_price|1': [12, ''],
          admin_base_price_status: 1,
          'admin_base_price|1': ['22', ''],
          admin_base_price_expire_at: '2023-01-01 12:12:12',
        },
      ],
    });
    const result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: data.list,
    };
    return res.json(result);
  },
  'POST /jdk/League/getOperateRecord': (req: Request, res: Response) => {
    const data = Mock.mock({
      'list|1-30': [
        {
          user: '暑夏',
          phone: '18505650937',
          text: '这是一段文案这是一段文案这是一段文案这是一段文案这是一段文案这是一段文案： 10元/单',
          time: '2020-09-07 12:30',
        },
      ],
    });
    const result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: data,
    };
    return res.json(result);
  },
  'POST /jdk/League/setServiceFeeByBrand': (req: Request, res: Response) =>
    // {
    //   return res.json({
    //     "code": 55555,
    //     "msg": "部分设置成功",
    //     "data": {
    //       "success_num": 0,
    //       "delivery_brand": "UU跑腿",
    //       "had_setting": [{ "nickname": "徐肖磊测试环", "phone": "15837899712" }, { "nickname": "徐肖磊测试环", "phone": "15837899712" }],
    //       "unbind_delivery": [{ "nickname": "13500000002", "phone": "13500000002" }]
    //     }
    //   })
    // },
    responseSuccess(req, res),
  'POST /jdk/League/deliveryBrandList': (req: Request, res: Response) => {
    const list = [
      {
        code: 'sftc',
        name: '顺丰同城',
      },
      {
        code: 'ddks',
        name: '达达',
      },
      {
        code: 'fnpt"',
        name: '蜂鸟',
      },
    ];
    const result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: list,
    };
    return res.json(result);
  },
};
